import util from '../../../utils/util'
import { ExchangeRecord, CheckGoods} from '../../../config/api'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isEmpty: false,
    flag:true,
    exchangeRecords:[],//兑换记录列表
    qrcodeUrl:'',//二维码地址链接
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      let member = wx.getStorageSync("member");
      console.log('code:',member.code);
      console.log('uid:',member.id);
      let params={
           code:member.code,
           uid:member.id,
           t:0,
           type:1,
           page:1,
           limit:100
      };
      // let params={
      //      code:"lt1",
      //      uid:39,
      //      t:0
      // };//测试数据

      let that = this;
      util.apiRequest(ExchangeRecord,params,null).then(r=>{
         console.log('兑换记录',r.data.data.data);
        if (r.data.data.data.length == 0) {
          that.setData({
            isEmpty: true
          })
        }
         that.setData({
             exchangeRecords:r.data.data.data
         });
      });

  },

  // 遮罩层显示
  showQrcode: function (e) {
       console.log('二维码链接Url:',e.currentTarget.dataset['url']);

    this.setData({
        flag: false ,
        qrcodeUrl:e.currentTarget.dataset['url']
    })
  },
  // 遮罩层隐藏
  conceal: function () {
    this.setData({ flag: true })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})
